<div class="wide form">

<?php $form=$this->beginWidget('CActiveForm', array(
	'action'=>Yii::app()->createUrl($this->route),
	'method'=>'get',
	'focus'=>Utils::AutoFocus($model, 'id')
)); ?>

	<div class="row">
		<?php echo $form->label($model,'id'); ?>
		<?php echo $form->textField($model,'id',array('size'=>20,'maxlength'=>20)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'name'); ?>
		<?php echo $form->textField($model,'name',array('size'=>60,'maxlength'=>60)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'first_name'); ?>
		<?php echo $form->textField($model,'first_name',array('size'=>60,'maxlength'=>64)); ?>
	</div>

	<div class="row">
		<?php echo $form->label($model,'last_name'); ?>
		<?php echo $form->textField($model,'last_name',array('size'=>60,'maxlength'=>100)); ?>
	</div>
	
	<div class="row">
		<?php echo $form->label($model,'username'); ?>
		<?php echo $form->textField($model,'username',array('size'=>60,'maxlength'=>60)); ?>
	</div>
	
	<div class="row">
		<?php echo $form->label($model,'email'); ?>
		<?php echo $form->textField($model,'email',array('size'=>60,'maxlength'=>100)); ?>
	</div>
	
	<div class="row">
		<?php echo $form->label($model,'join_date'); ?>
		<?php echo CHtml::hiddenField('join_date_from') ?>
		<?php echo CHtml::hiddenField('join_date_to') ?>
		<?php echo Yii::t('user','Từ ngày') ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
		    'name'=>'join_date_from_select',
		    'options'=>array(
				'altField'=>'#join_date_from',
				'altFormat'=>'mm/dd/yy',
				'changeYear'=>true,
		        'showAnim'=>'',
				'onSelect'=> 'js:function(dateText, inst){
					$("#date-error").hide();
					$("#join_date_to_select, #join_date_from_select").removeClass("error");
					
					var start = new Date($("#join_date_from").val());
					if($("#join_date_to").val()=="")
					{						
						var d = start.getDate();
						var m = start.getMonth();
						var y = start.getFullYear();
					 	var edate= new Date(y, m, d+7);
					
						$("#join_date_to_select").datepicker("setDate", edate);
					}
					else
					{
						var end = new Date($("#join_date_to").val());
						if(start.getTime() > end.getTime())
						{
							$("#join_date_to_select, #join_date_from_select").addClass("error");
							$("#date-error").show();
						}
					}
				}'
		    ),
			'htmlOptions'=>array(
				'placeholder'=>Yii::t('backend','Từ ngày...')
			)
		)); ?>
		<?php echo Yii::t('user','đến ngày') ?>
		<?php $this->widget('zii.widgets.jui.CJuiDatePicker', array(
		    'name'=>'join_date_to_select',
		    'options'=>array(
				'altField'=>'#join_date_to',
				'altFormat'=>'mm/dd/yy',
				'changeYear'=>true,
		        'showAnim'=>'',
				'onSelect'=> 'js:function(dateText, inst){
					$("#date-error").hide();
					$("#join_date_to_select, #join_date_from_select").removeClass("error");
					
					var end = new Date($("#join_date_to").val());
					if($("#join_date_from").val()=="")
					{
						var d = end.getDate();
						var m = end.getMonth();
						var y = end.getFullYear();
					 	var sdate= new Date(y, m, d-7);

						$("#join_date_from_select").datepicker("setDate", sdate);
					}
					else
					{
						var start = new Date($("#join_date_from").val());
						if(start.getTime() > end.getTime())
						{
							$("#join_date_to_select, #join_date_from_select").addClass("error");
							$("#date-error").show();
						}
					}
				}'
		    ),
			'htmlOptions'=>array(
				'placeholder'=>Yii::t('backend','...đến ngày')
			)
		)); ?>
		<div id="date-error" class="hide hint"><span class='error'><?php echo Yii::t('user','Ngày bắt đầu phải trước ngày kết thúc!') ?></span></div>
	</div>
	
	<div class="row buttons">
		<?php echo CHtml::submitButton(Yii::t('backend','Tìm kiếm'), array('class'=>'g-button g-button-submit')); ?>
		<?php echo CHtml::resetButton(Yii::t('backend','Làm lại'), array('class'=>'g-button')); ?>
	</div>

<?php $this->endWidget(); ?>

</div><!-- search-form -->